package com.jt.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jt.pojo.Item;
import com.jt.service.DubboItemService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class SearchController {

    @Reference(check = false, timeout = 3000)
    private DubboItemService itemService;

    @RequestMapping("search")
    public String search(String q, Model model) {
        System.out.println(q);
        List<Item> items = itemService.findByName(q);
        model.addAttribute("itemList", items);
        return "search";
    }
}
